package com.letoy.edu.service.Impl;

import com.letoy.edu.dao.VenuesInfoMapper;
import com.letoy.edu.entity.VenuesInfo;
import com.letoy.edu.service.VenuesInfoService;
import com.letoy.edu.socket.model.MyMessage;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class VenuesInfoServiceImpl implements VenuesInfoService {

    @Resource
    VenuesInfoMapper venuesInfoMapper;

    @Override
    public List<VenuesInfo> getAllVenuesInfo() {
        return venuesInfoMapper.getAllVenuesInfo();
    }

    @Override
    public int updateVenuesInfoById(VenuesInfo venuesInfo) {
        if (venuesInfoMapper.updateVenuesInfoById(venuesInfo) >= 1) {
            return 0;
        } else {
            return 10;
        }
    }

    @Override
    public int updateVenuesInfoByIdFromMyMessage(MyMessage myMessage) {
        VenuesInfo venuesInfo = new VenuesInfo();
        venuesInfo.setVenuesId(myMessage.getVenuesId());
        venuesInfo.setStatus(myMessage.getVenuesStatus());
        if (venuesInfoMapper.updateVenuesInfoById(venuesInfo) >= 1) {
            return 0;
        } else {
            return 10;
        }
    }
}
